{extend name="public:base" /}
{block name="title"}会员首页{/block}

{block name="content"}
    <section class="content">

        <div class="box box-solid">
            <div class="box-header with-border">
              <h3 class="box-title">密码设置</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
                <form role="form" id="operate">
                    <div class="form-group">
                      <label>会员账户</label>
                      <div class="row">
                      <div class="col-md-6">
                        {$info.username}
                        <input type="hidden" name="mid" value="{$info.mid}">
                      </div>
                      </div>
                    </div>
                    <div class="form-group">
                      <label>旧密码</label>
                      <div class="row">
                      <div class="col-md-6">
                      <input type="password" name="oldpassword" class="form-control input-sm" placeholder="">
                      </div>
                      </div>
                    </div>
                    <div class="form-group">
                      <label>新密码</label>
                      <div class="row">
                      <div class="col-md-6">
                      <input type="password" name="password" class="form-control input-sm" placeholder="">
                      </div>
                      </div>
                    </div>
                    <div class="form-group">
                      <label>确认新密码</label>
                      <div class="row">
                      <div class="col-md-6">
                      <input type="repassword" name="repassword" class="form-control input-sm" placeholder="">
                      </div>
                      </div>
                      <p class="help-block">请再次输入密码</p>
                    </div>
                </form>
            </div>
            <!-- /.box-body -->
            <div class="box-footer">
                <div class="btn-group">
                    <button class="btn btn-warning btn-flat" onclick="operate();" type="button">密码修改</button>
                </div>
            </div>
        </div>

    </section>
{/block}

{block name="js"}
<script type="text/javascript">
    function operate(){
        $.ajax({
            url:"{:url('member/member/password')}",
            data:$("#operate").serialize(),
            type:'post',
            dataType:'json',
            success:function(xhr){
                if(xhr.code == 200){
                    swal({
                      position: 'center',
                      type: 'success',
                      title: xhr.msg,
                      showConfirmButton: false,
                      toast:false,
                      timer: 2000
                    });
                } else{
                    swal({
                      position: 'center',
                      type: 'error',
                      title: xhr.msg,
                      showConfirmButton: false,
                      toast:false,
                      timer: 2000
                    });
                }
            }
        });
    }

</script>
{/block}